// 车辆增加统计
import i18n from '@/lang'
export default {
  initOptions: {
    xAxis: {
      type: 'category',
      boundaryGap: false,
      data: []
    },
    tooltip: {
      trigger: 'axis'
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true
    },
    yAxis: {
      type: 'value',
      minInterval: 1
    },
    series: []
  },
  setEchart (echartObject, xData, series) {
    echartObject.setOption(this.initOptions)
    const echartSeries = []
    if (Array.isArray(series)) {
      // 单条线
      echartSeries.push({
        name: '',
        type: 'line',
        data: series
      })
    } else {
      // 多条线
      for (const i in series) {
        echartSeries.push({
          name: i18n.t(i),
          type: 'line',
          data: series[i]
        })
      }
    }
    echartObject.setOption({
      xAxis: {
        data: xData
      },
      series: echartSeries
    })
    setTimeout(() => {
      echartObject.resize()
    })
  }
}
